package leetcode_day._2021._202105._2131;

/**
 * @author yzh
 * @version 1.0
 * @date 2021/5/27 22:21
 * 汉明距离
 * 算法；位运算
 */
public class _27_461 {

    public int hammingDistance(int x, int y) {
        int ans = 0;
        for (int i = 31; i >= 0; i--) ans += (x >> i & 1) ^ (y >> i & 1);
        return ans;
    }

}
